<template>
  <div class="inner-container">
    <el-table v-loading="loading" :data="tableData" >
      <el-table-column prop="releaseTime" label="发布时间" min-width="128"/>
      <el-table-column prop="releaseTitle" label="公告标题" show-overflow-tooltip/>
      <el-table-column prop="publisher" label="发布人"/>
      <el-table-column label="操作">
        <template #default="scope">
          <el-button type="primary" link icon="View"  @click="detail(scope.row.id)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <br>
    <el-pagination
        :total="total"
        v-model:current-page="queryParams.pageNum"
        v-model:page-size="queryParams.pageSize"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
    />
  </div>
</template>

<script setup>
import {onMounted, ref} from 'vue'
import request from '/src/utils/request'
import router from "@/router";

// --------------------------------------------------
const loading = ref(false)
const queryParams = ref({pageNum: 1, pageSize: 10})
const total = ref(0)
const tableData = ref([])
const listData = () => {
  loading.value = true
  let data = {...queryParams.value}
  console.log(data);
  request.get('/api/crm/notice/selectByStatus', {
    params: data
  }).then(res => {
    total.value = res.data.total;
    tableData.value = res.data.list;
    console.log(res.data)
    loading.value = false
  })
}

const handleCurrentChange = (val) => {
  queryParams.value.pageNum = val
  listData()
}

const handleSizeChange = (val) => {
  queryParams.value.pageSize = val
  listData()
}
//查看详情
const detail = (id) => {
  router.push('/system/notice/detail?id=' + id);

}
// --------------------------------------------------
onMounted(() => {
  listData();
})
</script>

<style scoped>

</style>
